home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ShareWare OnLine 2
/
ShareWare OnLine Volume 2 (CMS Software)(1993).iso
/
prog
/
pbc22b.zip
/
PBC$BAS.ZIP
/
FMTPHONE.BAS
< prev
next >
Wrap
BASIC Source File
|
1993-04-18
|
1KB
|
36 lines
' +----------------------------------------------------------------------+
' | |
' | PBClone Copyright (c) 1990-1993 Thomas G. Hanlin III |
' | |
' +----------------------------------------------------------------------+
DECLARE FUNCTION AscM% (St$, BYVAL Posn%)
DECLARE FUNCTION UpcaseI% (BYVAL Ch%)
FUNCTION FormatPhone$ (RawSt$)
'--- toss any characters that aren't alphanumeric, 'n' also Q and Z
st$ = ""
FOR tmp% = 1 TO LEN(RawSt$)
ch% = UpcaseI%(AscM%(RawSt$, tmp%))
IF ch% >= 48 AND ch% <= 57 OR ch% >= 65 AND ch% < 90 AND ch% <> 81 THEN
st$ = st$ + CHR$(ch%)
END IF
NEXT
'--- format the result based on the string length
IF LEN(st$) = 11 AND LEFT$(st$, 1) = "1" THEN
st$ = MID$(st$, 2)
END IF
SELECT CASE LEN(st$)
CASE 4
FormatPhone$ = st$
CASE 7
FormatPhone$ = LEFT$(st$, 3) + "-" + RIGHT$(st$, 4)
CASE 10
FormatPhone$ = "(" + LEFT$(st$, 3) + ") " + MID$(st$, 4, 3) + "-" + RIGHT$(st$, 4)
CASE ELSE
FormatPhone$ = ""
END SELECT
END FUNCTION